package backTrack;

import java.util.*;

public class ds78 {
    public static void main(String[] args) {
        System.out.println(subsets(new int[]{1,2,3}));
    }

    public static List<List<Integer>> subsets(int[] nums) {
        List<List<Integer>> ans = new ArrayList<>();
        List<Integer> path = new ArrayList<>();
        dfs(nums, 0, ans, path);
        return ans;
    }
    public static void dfs(int[] nums, int index,List<List<Integer>> ans, List<Integer> path){
        if(index > nums.length)
            return;
        ans.add(new ArrayList<>(path));
        for (int i = index; i < nums.length; i++) {
            path.add(nums[i]);
            dfs(nums, i + 1, ans, path);
            path.remove(path.size() - 1);
        }
    }
}
